﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BitAuto.EP.CRMLogSystem.DAL;
using BitAuto.EP.CRMLogSystem.Entity;

namespace BitAuto.EP.CRMLogSystem.BLL
{
    public static class InputDBBLL
    {
        public static void BulkToDB(LogTableInfo info)
        {
            if (info == null || info.Table == null || info.Table.Rows == null || info.Table.Rows.Count == 0) return;
            InputDBDAL.BulkToDB(info);
        }
        public static IDictionary<string, Exception> BulkToDB(IList<LogTableInfo> info)
        {
            IDictionary<string, Exception> dic = null;
            foreach (var item in info)
            {
                try
                {
                    BulkToDB(item);
                    item.Clear();
                }
                catch (Exception ex)
                {
                    if(dic==null)dic=new Dictionary<string, Exception>(info.Count);
                    dic.Add(item.LogTableId,ex);
                }
            }
            return dic;
        }
    }
}
